#include "parafluidsubstance.h"

using namespace ParaFluid;

const Substance Substance::WATER(1.0, Color(0, 0, 1.0), 1.0, 0.0, 1.0);

Substance::~Substance()
{
	/* does nothing */
}

Substance::Substance()
	: mass(1.0)
	, color()
	, pressureFactor(1.0)
	, restDensity(0.0)
	, viscosityFactor(1.0)
{
	/* does nothing */
}

Substance::Substance(float Mass, const Color & Color, float PressureFactor, float RestDensity, float ViscosityFactor)
	: mass(Mass)
	, color(Color)
	, pressureFactor(PressureFactor)
	, restDensity(RestDensity)
	, viscosityFactor(ViscosityFactor)
{
	/* does nothing */
}

Substance::Substance(const Substance & other)
	: mass(other.mass)
	, color(other.color)
	, pressureFactor(other.pressureFactor)
	, restDensity(other.restDensity)
	, viscosityFactor(other.viscosityFactor)
{
	/* does nothing */
}

Substance & Substance::operator= (const Substance & rhs)
{
	if(&rhs != this)
	{
		mass = rhs.mass;
		color = rhs.color;
		pressureFactor = rhs.pressureFactor;
		restDensity = rhs.restDensity;
		viscosityFactor = rhs.viscosityFactor;
	}
	return *this;
}

bool Substance::operator== (const Substance & rhs) const
{
	bool result = true;
	if(&rhs != this)
	{
		result = (mass == rhs.mass)
		&& (color == rhs.color)
		&& (pressureFactor == rhs.pressureFactor)
		&& (restDensity == rhs.restDensity)
		&& (viscosityFactor == rhs.viscosityFactor);
	}
	return result;
}

QDataStream & operator<< (QDataStream & stream, const ParaFluid::Substance & substance)
{
	stream << substance.mass;
	stream << substance.color;
	stream << substance.pressureFactor;
	stream << substance.restDensity;
	stream << substance.viscosityFactor;
	return stream;
}
	
QDataStream & operator>> (QDataStream & stream, ParaFluid::Substance & substance)
{
	stream >> substance.mass;
	stream >> substance.color;
	stream >> substance.pressureFactor;
	stream >> substance.restDensity;
	stream >> substance.viscosityFactor;
	return stream;	
}
